package bairui.international.model.domain.jpa;

import bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord;

/**
 *
 * (产品订单状态记录)TB_ProductOrderStateRecord
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_ProductOrderStateRecord#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_productOrderStateRecord")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("产品订单状态记录")
@com.lianjing.sh.processing.info.annotation.InfoComment("产品订单状态记录")
public class TB_ProductOrderStateRecord
 extends TBSuper_StateVerifyRecord
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 类型 */
		public bairui.international.model.type.Type_StateRecord getType();
		/** 说明 */
		public String getCommentate();
		/** 产品订单 */
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_ProductOrderStateRecord properties(MustProperties properties) {
		this.setType(properties.getType());
		this.setCommentate(properties.getCommentate());
		this.setProductOrder(properties.getProductOrder());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_ProductOrderStateRecord(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 消息 */
		public String getMessage();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_ProductOrderStateRecord properties(OptionalSingleProperties properties) {
		this.setMessage(properties.getMessage());
		return this;
	}
	
	
	
	public TB_ProductOrderStateRecord(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 产品订单 */
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_ProductOrderStateRecord properties(CurrentMustProperties properties) {
		this.setProductOrder(properties.getProductOrder());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_ProductOrderStateRecord properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_ProductOrderStateRecord(
		@lombok.NonNull bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_ProductOrderStateRecord(
		@lombok.NonNull bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord bean
	) {
		update(bean);
	}
	
	public TB_ProductOrderStateRecord update(bairui.international.model.domain.jpa.TBSuper_StateVerifyRecord bean){
		this.setId(bean.getId());
		this.setMessage(bean.getMessage());
		this.setType(bean.getType());
		this.setCommentate(bean.getCommentate());
		this.setCreateTime(bean.getCreateTime());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			String message = getMessage(TB_ProductOrderStateRecord.this);
			if(isOverride_getMessage){
				TB_ProductOrderStateRecord.this.setMessage(message);
			}
	
			bairui.international.model.type.Type_StateRecord type = getType(TB_ProductOrderStateRecord.this);
			if(isOverride_getType){
				TB_ProductOrderStateRecord.this.setType(type);
			}
	
			String commentate = getCommentate(TB_ProductOrderStateRecord.this);
			if(isOverride_getCommentate){
				TB_ProductOrderStateRecord.this.setCommentate(commentate);
			}
	
			bairui.international.model.domain.jpa.TB_ProductOrder productOrder = getProductOrder(TB_ProductOrderStateRecord.this);
			if(isOverride_getProductOrder){
				TB_ProductOrderStateRecord.this.setProductOrder(productOrder);
			}
		}
	
		public TB_ProductOrderStateRecord up(){
			return TB_ProductOrderStateRecord.this;
		}
	
		/** 消息 */
		private boolean isOverride_getMessage = true;
		public String getMessage(TB_ProductOrderStateRecord it) throws Exception { 
			isOverride_getMessage = false; 
			return null;
		}
		/** 类型 */
		private boolean isOverride_getType = true;
		public bairui.international.model.type.Type_StateRecord getType(TB_ProductOrderStateRecord it) throws Exception { 
			isOverride_getType = false; 
			return null;
		}
		/** 说明 */
		private boolean isOverride_getCommentate = true;
		public String getCommentate(TB_ProductOrderStateRecord it) throws Exception { 
			isOverride_getCommentate = false; 
			return null;
		}
		/** 产品订单 */
		private boolean isOverride_getProductOrder = true;
		public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder(TB_ProductOrderStateRecord it) throws Exception { 
			isOverride_getProductOrder = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_ProductOrderStateRecord() {
	}
	
	public TB_ProductOrderStateRecord(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_ProductOrderStateRecord(
		@lombok.NonNull TB_ProductOrderStateRecord bean
	) {
		this.setId(bean.getId());
		this.setMessage(bean.getMessage());
		this.setType(bean.getType());
		this.setCommentate(bean.getCommentate());
		this.setCreateTime(bean.getCreateTime());
		this.setProductOrder(bean.getProductOrder());
		this.setLastModifier(bean.getLastModifier());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("产品订单")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品订单")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_ProductOrder productOrder;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=true)
	@javax.persistence.ManyToOne()
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	/** get[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder getProductOrder() {
		return this.productOrder;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** set[产品订单] */
	public void setProductOrder(bairui.international.model.domain.jpa.TB_ProductOrder productOrder) {
		this.productOrder = productOrder;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	public void assignProductOrder(bairui.international.model.domain.jpa.TB_ProductOrder productOrder) {
		if(null != productOrder){
			productOrder.addProductOrderStateRecords(this);
		}
		this.setProductOrder(productOrder);
	}
	


	
	
	

	/** take[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder takeProductOrder(){
		if(null == this.productOrder){
			this.productOrder = new bairui.international.model.domain.jpa.TB_ProductOrder();
		}
		return this.productOrder;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** must[产品订单] */
	public bairui.international.model.domain.jpa.TB_ProductOrder mustProductOrder() {
		return this.productOrder;
	}
	
	/** optional[最后修改者] */
	public java.util.Optional<bairui.international.model.domain.jpa.TB_Admin> optionalLastModifier() {
		return java.util.Optional.ofNullable(this.lastModifier);
	}
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_ProductOrderStateRecord other = (TB_ProductOrderStateRecord) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}



}
